﻿using System;

namespace TheSnake
{
    public class Food : StaticObject
    {
        public new const string CollisionGroupString = "food";
        public const char Symbol = '#';
        private const int Seed = 182736;
        private Random randomGenerator = new Random(Seed);

        private int startRow = 4;
        private int startCol = 1;
        private int endRow = 20;
        private int endCol = 53;

        public Food(MatrixCoords topLeft)
            : base(topLeft, new char[,] { { Symbol } })
        {
            
        }

        public override string GetCollisionGroupString()
        {
            return Food.CollisionGroupString;
        }

        public override void RespondToCollision(CollisionData collisionData)
        {
            if (collisionData.hitObjectsCollisionGroupStrings[0] == "snake")
            {
                this.TopLeft = new MatrixCoords(
                    randomGenerator.Next(startRow, endRow - 1),
                    randomGenerator.Next(startCol, endCol - 1));
            }
        }

        public override bool CanCollideWith(string otherCollisionGroupString)
        {
            return otherCollisionGroupString == "snake";
        }

        public void ChangePosition(int seed = Seed)
        {
            randomGenerator = new Random(seed);
            this.TopLeft = new MatrixCoords(
                    randomGenerator.Next(startRow, endRow - 1),
                    randomGenerator.Next(startCol, endCol - 1));
        }

        public override void Update()
        { 
        }
    }
}
